package com.cong.modules.news.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cong.common.util.StringUtils;
import com.cong.modules.news.mapper.NewsCategoryMapper;
import com.cong.modules.news.model.NewsCategory;
import com.cong.modules.news.service.INewsCategoryService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 新闻分类表 服务实现类
 */
@Service
public class NewsCategoryServiceImpl extends ServiceImpl<NewsCategoryMapper, NewsCategory>
		implements INewsCategoryService {

	@Resource
	private NewsCategoryMapper newsCategoryMapper;

	@Override
	public List<NewsCategory> listNewsCategory(NewsCategory newsCategory) {
		LambdaQueryWrapper<NewsCategory> queryWrapper = new LambdaQueryWrapper<>();
		if (StringUtils.isNotEmpty(newsCategory.getCategoryName())) {
			queryWrapper.like(NewsCategory::getCategoryName, newsCategory.getCategoryName());
		}
		if (newsCategory.getStatus() != null) {
			queryWrapper.eq(NewsCategory::getStatus, newsCategory.getStatus());
		}
		return newsCategoryMapper.selectList(queryWrapper);
	}

}
